package com.java.simple.study.jvm.classloader;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

/**
 * @author zhoujunlin
 * @date 2023年01月31日 10:41
 * @desc
 */
public class StringClass {

    public static void main(String[] args) throws ClassNotFoundException {
        Class<?> clazz = Class.forName("java.lang.String");
        Method[] declaredMethods = clazz.getDeclaredMethods();
        for (Method declaredMethod : declaredMethods) {
            // 获取方法修饰符
            String modifier = Modifier.toString(declaredMethod.getModifiers());
            System.out.print(modifier + " ");

            // 获取方法返回值类型
            String returnType = declaredMethod.getReturnType().getSimpleName();
            System.out.print(returnType + " ");

            // 获取方法名
            System.out.print(declaredMethod.getName() + "(");

            // 获取参数列表
            Class<?>[] parameterTypes = declaredMethod.getParameterTypes();
            if (parameterTypes.length == 0) {
                System.out.print(")\n");
            }

            for (int i = 0; i < parameterTypes.length; i++) {
                String end = (i == parameterTypes.length - 1) ? ")\n" : ",";
                System.out.print(parameterTypes[i].getSimpleName() + end);
            }

        }
    }


}
